package com.hnn;

import cn.hutool.core.util.StrUtil;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author hnn
 * @version 1.0
 * @date 2023-11-03 18:48
 */
public class TestProcess {



    public static void main(String[] args) throws IOException {
        test();
        System.out.println("Hello world!");
    }

    public static void test() {
        try {
            File dir=new File("learn_util");
            System.out.println(dir.getAbsolutePath());
            ProcessBuilder pb = new ProcessBuilder(dir.getAbsolutePath()+"\\test.bat")

                    .directory(dir.getAbsoluteFile());
            Process p = pb.start();

            System.out.println(p.waitFor());

            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String r;
            while (null!=(r = bufferedReader.readLine())) {
                System.out.println(r);
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
